import json

from flask import request, Blueprint

from virtual_operator_service_base.service.dns.domain_dns_service import DomainDnsService
from virtual_operator_service_base.utils.g import G
from virtual_operator_service_base.utils.logger_util import logger
from virtual_operator_service_base.utils.response import SUCCESS, FAIL

domain_dns_operator_bp = Blueprint(
    'domain_dns_operator_bp', __name__,
    url_prefix='/v1/virtual-operator/domain-dns')


@domain_dns_operator_bp.route('/demo', methods=['POST'])
def domain_dns_add():
    try:
        # TODO do something
        demo = DomainDnsService.domain_dns_add("xxx.com.cn", "127.0.0.1")
        return SUCCESS.result({
            "result": True
        })
    except Exception as e:
        logger.exception("bad request body, pls try again!", e)
        return FAIL.result({
            "error_message": "bad request body, pls try again!"
        })
